home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / gse < prev    next >
Text File  |  1995-03-31  |  10KB  |  263 lines

  1. Article 6419 of comp.sys.handhelds:
  2. Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!news.cs.indiana.edu!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!hp-pcd!hpcvra.cv.hp.com!rnews!hpcvbbs!akcs.joehorn
  3. From: akcs.joehorn@hpcvbbs.UUCP (Joseph K. Horn)
  4. Newsgroups: comp.sys.handhelds
  5. Subject: HP48 Goal Seeking Engine
  6. Keywords: hp 48 gse
  7. Message-ID: <281faead:3000comp.sys.handhelds@hpcvbbs.UUCP>
  8. Date: 2 May 91 06:40:11 GMT
  9. Lines: 249
  10.  
  11. This is being posted for a friend.
  12.  
  13. -------------------------------------
  14.  
  15. GSE1 Directory - Goal Seeking Engine version 1 - 4/91
  16. Copyright 1991, Jeff Duncombe
  17.  
  18.  [Note: Included on EduCALC Goodies Disk #3 with Jeff's permission.
  19.  -jkh-]
  20.  
  21. What if one program could find out the fewest number of
  22. floppies to copy your enormous number of files onto?  Or maybe
  23. balance your checkbook?  What about making perfectly timed audio
  24. cassettes?
  25.  
  26. GSE is a utility for finding what combination of a group of
  27. numbers will total to a goal number (within a certain accuracy).
  28. There are many applications that are tailor-made to this type of
  29. an engine; three are provided for example.
  30.  
  31. The basic stack setup is as follows:
  32.  
  33. 3:[Vector of numbers]
  34. 2:Goal=====>
  35. 1:Accuracy1:[Answer Vector]
  36.  
  37. For example, assume there are a group of numbers: 6, 4, 3, 2.
  38. What combination of these numbers will equal 7?
  39.  
  40. Load the stack as follows:
  41. 3: [6 4 3 2]yields
  42. 2: 7=====>
  43. 1: 01: [0 4 3 0]
  44.  
  45. This means that of the four item list, the combination of 4 and 3
  46. will yield the goal of 7.
  47.  
  48. Not very exciting, you say?  Here's a better one: you have a
  49. directory of 8 files (100K, 230K, 310K, 130K, 170K, 50K, 260K, 190K).
  50. Assume that you want to put these onto the fewest number of 360K
  51. floppies.  If you total them (put the vector in level 1 and CNRM),
  52. you will find they total 1440K, or 4 x 360K disks.  But if you use
  53. the standard COPY command, they will end up taking 5 diskettes, as
  54. follows:
  55.  
  56. 100K   230K |  310K  | 130K   170K |  50K   260K |   190K
  57.   Disk 1    | Disk 2 | Disk 3    |Disk 4 |  Disk 5
  58.  
  59. This is a problem for GSE! it will find you a way using only 4 disks!
  60. (Hint: It is a good idea to have the original vector in 3 and 4, so
  61. a copy will still be available).
  62.  
  63. Load the stack:
  64. 4:[100 230 310 130 170 50 260 190]
  65. 3:[100 230 310 130 170 50 260 190]
  66. 2:360=====>2:[100 230 310 130 ...]
  67. 1:01:[100 0 0 0 0 0 260 0]
  68.  
  69. The first answer! 100K and 260K should fill the first disk! Notice
  70. that flag 1 is set on the screen, which means that the goal of 360
  71. was found within the desired accuracy of 0.  If flag 1 was clear, the
  72. best answer would be displayed, but it wouldn't be within the limits.
  73.  
  74. Now do a [-] (the minus key) and [ENTER].  This will take out the
  75. known solution from the list and leave you with the next argument
  76. (properly DUPlicated). Fill 1 & 2 with the desired info and try
  77. it again:
  78.  
  79. 4:[0 230 310 130 170 50 0 190]
  80. 3:[0 230 310 130 170 50 0 190]
  81. 2:360=====>2:[0 230 310 130 17...]
  82. 1:01:[0 230 0 130 0 0 0 0]
  83.  
  84. The next answer is 230K and 130K.  After a [-], [ENTER], 360 and 0, 
  85. you continue:
  86.  
  87. 4:[0 0 310 0 170 50 0 190]
  88. 3:[0 0 310 0 170 50 0 190]
  89. 2:360=====>2:[0 0 310 0 170 50...]
  90. 1:01:[0 0 310 0 0 50 0 0]
  91.  
  92. The third disk shall hold the 310K file and the 50K file. [-], [ENTER],
  93. 360, 0 :
  94.  
  95. 4:[0 0 0 0 170 0 0 190]
  96. 3:[0 0 0 0 170 0 0 190]
  97. 2:360=====>2:[0 0 0 0 170 0 0 ...]
  98. 1:01:[0 0 0 0 170 0 0 190]
  99.  
  100. The fourth and final disk should therefore hold 170K and 190K.
  101.  
  102. The possibilities are endless.As another example, say that
  103. you needed to balance your checkbook.  Just type in a vector of all
  104. the checks that you wrote, then set your final balance as the goal
  105. (don't forget any little bank fees).  Follow the example below:
  106.  
  107. You've written checks for $32.56, $27.90, $130.21, and $46.35. 
  108. Your total for checks written is $106.81. Solve:
  109.  
  110. 3:[32.56 27.90 130.21 46.35]
  111. 2:106.81=====>
  112. 1:01:[32.56 27.9 0 46.35]
  113.  
  114. The check for 130.21 must still be uncashed.
  115.  
  116. As the last example, I will use the problem that inspired me to write
  117. this program in the first place.  I want to tape some songs from CD 
  118. to audio cassette.  The cassette is 45 minutes on each side, for a 
  119. total of 90 minutes.  There should be a way to place the songs
  120. selectively on each side so as to fit every song in its entirety.
  121. This is more difficult than it sounds, if you don't have a computer, 
  122. because there are generally 20+ songs to deal with.  Anyway, here
  123. are the song lengths (in seconds):
  124.  
  125. [540 482 669 841 334 592 604 612 381 344]
  126.  
  127. The goal is 2700 seconds (45 minutes).The accuracy will be 0.
  128.  
  129. 4:[540 482 669 841 ...]
  130. 3:[540 482 669 841 ...]
  131. 2:2700=====>2:[540 482 669 841 ...]
  132. 1:01:[540 0 0 841 334 ...]
  133.  
  134. The first side of the tape must contain the songs the are lengths
  135. 540, 841, 334, 604, and 381 for a total of exactly 2700 seconds.  A
  136. simple [-] and you get what songs go on the second side (482, 669, 
  137. 592, 612, and 344).
  138.  
  139. (Note: I have tried this method, and it works amazingly well.)
  140.  
  141. That's it for the examples. Here are just a few random specs to help 
  142. you on your way:
  143.  
  144. * This engine uses error checking, so don't worry about your arguments
  145. causing a system crash.
  146.  
  147. * Flags 1, 2, & 3 are used by this program.  They are all cleared at
  148. the beginning and modified during the course of the execution.Their
  149. descriptions are as follows:
  150.  
  151. SetClear
  152.  
  153. Flag 1: The answer is withinThe answer is the closest to
  154. the desired accuracy.the accuracy as possible, but
  155. NOT within it.
  156.  
  157. Flag 2: The argument is a two-The program runs normally.
  158. dimensional array. The
  159. arguments are left alone.
  160.  
  161. Flag 3: (This flag is always clear at the end of the engine)
  162.  
  163. * If a complex vector is given as an argument, it will be converted
  164. to the real part only.Example: [(2,3) (4,5) (6,4) (3,2)] would be
  165. considered to be [2 4 6 3]. 
  166.  
  167. Note: The [-] still works with a complex and a real-only vector, as
  168. shown:
  169.  
  170. 2:[(2,3) (4,5) (6,4)] [-]
  171. 1:[0 4 0]=====>1:[(2,3) (0,5) (6,4)]
  172.  
  173. * Although GSE appears to be the only program in the GSE1 directory,
  174. there are three "hidden" files called GSEV, GSER, and MMUL.  These
  175. programs are subroutines of GSE, and should not be used alone, for
  176. they can cause a Memory Clear if not used correctly.  GSE uses them
  177. correctly, so they are hidden from the VAR menu.  But this means
  178. that the GSE program cannot be removed from the GSE1 directory and
  179. used alone.  If you wish to call GSE from your own software, you
  180. may make the GSE1 directory into a library.  [See USRLIB on EduCALC
  181. Goodies Disk #1.  -jkh-]
  182.  
  183. Now for the disclaimer:
  184. This program contains undocumented features of the HP 48SX and
  185. consequently I bear no responsibility for any damage it may cause.
  186. (I haven't ever had a problem, though).
  187.  
  188. If you decide that this engine is worth while to use in your personal
  189. or commercial applications, I would appreciate some compensation for
  190. this.  This first version contains only the "bare-bones" of what I 
  191. have envisioned this application to be.  Future releases shall include 
  192. batch goal-seeking (having multiple goals with the same vector and
  193. minimizing the overall difference), speed enhancements (in theory
  194. there should be a big future for this one), and some bonus features.
  195. Remember, the only way to be alerted to these changes is to register
  196. for that privilege.  Send your donations to:
  197.  
  198. Jeff Duncombe
  199. PO Box 20098
  200. Fountain Valley, CA 92708
  201.  
  202. (Suggested amounts are $10 for personal use, commercial royalties may 
  203. vary.  Contact me for details.)
  204.  
  205. Happy Goal Seeking!
  206.  
  207. ASC-encoded GSE1 directory; use ASC-> or ASC2BIN to convert.
  208.  
  209. %%HP: T(3)A(D)F(.);
  210. "69A20FF7174000000040D4D455C440D9D20E16321C432D6E201087D6E201097E
  211. 1632D6E2010978B9C1EB3A19C2A2DBBF10A132D6E201096D6E201087D6E20109
  212. 66C7D1D6E201097D6E2010966C7D1EEDA1C4232D6E2010878B9C1900D1EF5329
  213. 3632B21307B000407435542540D9D20E16323CE229C2A2973C1AFE22D9D20940
  214. 405233094040523301C432D6E201096E163233032D6E201096530402E230EBBE
  215. 1D5032D9D20C1216D6E201096B68D12A6F088130B20402E230D6E2010969C2A2
  216. ED4D1B20405031644230E9330C1216477F0F1AA188130350402E2303CE22EBBE
  217. 1AFE22D9D2088130940405031644230E9330B20402E230F30405031644230E93
  218. 3088130C12163CE22CFCE1AFE22D9D209C2A2D82C1B21305DF22B21305DF227A
  219. 726C12163CE22EBBE1AFE22D9D2088130D6E2010969C2A22A6F035040E933035
  220. 040E933035040E933084E204074355425B21305BF22D9D2091136B21305DF22E
  221. F116D6E201096B68D1940405233032230477F0120402E230D6E2010964B2A2ED
  222. 4D1120405031644230E933045632D6E201096976320890244230B213049632EF
  223. 53244230B21305BF22D9D209404052330940405233085230B21305DF2293632B
  224. 21306B200407435546540D9D20E16325923088130AC7C1E90168B9C18B9C13CE
  225. 229C2A2D9AE1AFE22D9D20ED2A2D82C1B21305BF22D9D2032230881303CE224B
  226. 2A2EBBE1AFE22D9D2059230599A1CAF06599A13F2A2D82C1B21305DF2232230F
  227. 1AA1B21305DF2293632B2130FC00000339200000000000000000710003074355
  228. 430D9D20E1632D9D200FE81C2F46D9D20E16329C2A2EE2C1ED2A2EE2C13F2A2E
  229. E2C184E2040743554653CE22ED2A2973C1AFE22D9D20EF116881308B9C188130
  230. EB3A19C2A22A6F0AF016881304B2A28813094040E9330681D1AF0169C2A28813
  231. 094040E9330681D14CB26EBFB14CB2684E20407435542585230322306272684E
  232. 2040D4D455C43223044230B21305DF223CE223F2A21A4C1AFE22599A15DF2293
  233. 632B2130B213093632B21304887"
  234.  
  235. 'GSE1' BYTES --> #7884h, 756.
  236.  
  237. And here it is uuencoded:
  238.  
  239. BEGIN--cut here--CUT HERE--
  240.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257. D0"0#*S%0_2+#+C(O*J'$H>\BE:E1_2(Y-K(2`RLQD&,C*S$`
  258. `
  259. end
  260. END--cut here--CUT HERE--
  261.  
  262.  
  263.